sr=44100
kr=4410
nchnls=2


            FLpanel   "rotator", 600, 800
  knull, giphase FLslider "phase", 0, 1, 0, 3, -1, 500, 40, 10, 10
            FLsetColor  0, 0, 0, giphase
            FLsetColor2   255, 255, 255, giphase
  knull, gidiff FLslider  "diff", -1, 1, 0, 3, -1, 500, 40, 10, 100
  knull, gipos FLbutton   "@circle", 0, 1, 1, 10, 10, 295, 495, -1
            FLpanelEnd
            FLrun     


    instr 1 
  kmask     linuxjoystick   0, 1
;;; this uses the first two axes on your joystick.
  kaxes     tab       0, 1
  kb0       tab       kaxes+2, 1
  kx        tab       2, 1
  ky        tab       3, 1
  kz        tab       4, 1
  ; kline     phasor    0.01
  ; kline     =  (kline-0.5)*(2*$M_PI)
  ; kx        =  sin(kline)
  ; ky        =  cos(kline)
  k_r, ktheta  cart2polar   kx, ky
  k_r2, kangdiff angle   kx, ky
  isz       tableng   2
  ifactor   = 100

  kpos      init      0
  kpos      =  kpos + kangdiff*ifactor
  kwrappos  wrap      kpos/isz, 0, 1
            FLsetVal  abs(kangdiff), kwrappos, giphase
            FLsetVal  abs(kangdiff), kangdiff/$M_PI, gidiff
            schedkwhen  abs(kangdiff), 0.15, 1, 2, 0, 0, kx/32768, ky/32768
  aph       interp    kpos
  aph       butlp     aph, 0.25
  aphase    wrap      aph, 0, isz-1
  ; aphase    phasor    0.1              
  ; aphase    =  aphase * (isz-1)
  ; kamp      =  ampdb((32768-k_r)/-372.5)*((kz+65536)/16384)
  ; kamp      limit     kamp, 0, 2
  ; kamp      =  kamp*32767
;  if kb0 == 0 kgoto play
  ; ain       inch      0
  ;           tablew    ain*kamp, aphase, 2
  ;           kgoto     done
; play:
  kamp      =  32767
  aout      tab       aphase, 2
            outs      aout*kamp, aout*kamp
;done:
    endin

    instr 2
            FLhide    gipos
            FLsetPosition   (p4*290)+295, (p5*290)+495, gipos
            FLshow    gipos
    endin